home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / SAT 2.3.7 / Demos / Demo ƒ / StepPlatform Demo ƒ / InformUser.p < prev    next >
Encoding:
Text File  |  1995-09-03  |  3.1 KB  |  152 lines  |  [TEXT/PJMM]

  1. (**************************************}
  2. {* displaying information on the screen}
  3. {*    and updating it.}
  4. {**************************************)
  5.  
  6. unit InformUser;
  7. interface
  8.     uses
  9. {$ifc UNDEFINED THINK_PASCAL}
  10.         Types, QuickDraw, Menus, Windows, TextEdit, Fonts, Dialogs, Memory, {}
  11. {$endc}
  12.         SAT, PlatformGlobals, sPlayerSprite;
  13.  
  14.     procedure InitInformationArea;
  15.     procedure DrawProgInfo (me: PlSpritePtr);
  16.     procedure UpdateInfo (me: PlSpritePtr);
  17.     procedure DrawProgrammerInfo;
  18.  
  19. implementation
  20.  
  21. {var SpritePtr    playerSp:extern; {Skall fixas genom uses!}
  22.  
  23.  
  24.     var
  25.         aActionMsg: array[0..10] of Str255;
  26.         lastActMsg: Integer;
  27.  
  28.     procedure InitInformationArea;
  29.         var
  30.             sh: StringHandle;
  31.             i: Integer;
  32.             r: Rect;
  33.             tmpPort: SATPort;
  34.  
  35.     begin
  36.         lastActMsg := -1;
  37.         i := 0;
  38.         repeat
  39.             begin
  40.                 sh := GetString(128 + i);
  41.                 if (sh <> nil) then
  42.                     aActionMsg[i] := sh^^;
  43.                 i := i + 1;
  44.             end;
  45.         until not ((i < ActionMsgNumber) and (sh <> nil));
  46.  
  47.         SATGetPort(tmpPort);
  48.         DrawProgInfo(playerSp);
  49.         SetRect(r, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  50.         SATBackChanged(r); (*Let SAT show it on screen*)
  51.         SATSetPort(tmpPort);
  52.     end; {InitInformationArea}
  53.  
  54.     procedure DrawProgInfo (me: PlSpritePtr);
  55.         var
  56.             s: Str255;
  57.             r: Rect;
  58.     begin
  59.         SetPort(gSAT.backScreen.port);
  60.         BackColor(blackColor);
  61.  
  62.         SetRect(r, 0, 0, gSAT.bounds.right, 18);
  63.  
  64.         ForeColor(blueColor);
  65.         EraseRect(r);
  66.         PenNormal;
  67.  
  68.         FrameRect(r);
  69.         SetRect(r, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  70.         FrameRect(r);
  71.  
  72.         ForeColor(redColor);
  73.         MoveTo(10, 13);
  74.         DrawString('This is a Demo for Scrolling and Platform Game.(made by Nissan Zafrir 1995)');
  75.  
  76.         SetRect(r, 1, 350, gSAT.offSizeH - 150, 366);
  77.         EraseRect(r);
  78.         ForeColor(yellowColor);
  79.  
  80.         MoveTo(10, 362);
  81.         DrawString('Speed.V = ');
  82.  
  83. (*** Displaying SpeedV info ***\}
  84. {NumToString(me->speed.v, s);}
  85. {MoveTo(100, 362);}
  86. {DrawString("\pSpeed.V = ");}
  87. {MoveTo(170, 362);}
  88. {DrawString(s);}
  89. {*******************************)
  90.         MoveTo(110, 362);
  91.         DrawString('Action = ');
  92.  
  93.         MoveTo(700, 362);
  94.         DrawString('H = ');
  95.  
  96. (*** Displaying PositionV info ***\}
  97. {MoveTo(350,362);}
  98. {DrawString("\pV = ");}
  99. {MoveTo(370,362);}
  100. {NumToString(me->position.v, s);}
  101. {DrawString(s);}
  102. {**********************************)
  103.         ForeColor(blackColor);
  104.         BackColor(whiteColor);
  105.     end; {DrawProgInfo}
  106.  
  107.     procedure UpdateInfo (me: PlSpritePtr);
  108.         var
  109.             s: Str255;
  110.             sh: StringHandle;
  111.             r: Rect;
  112.     begin
  113.         BackColor(blackColor);
  114.         ForeColor(yellowColor);
  115.  
  116.         SetRect(r, 80, 350, 110, 366);
  117.         EraseRect(r);
  118.         NumToString(me^.speed.v, s);
  119.         MoveTo(80, 362);
  120.         DrawString(s);
  121.  
  122.         if (me^.action <> lastActMsg) then
  123.             begin
  124.                 SetRect(r, 165, 350, 310, 366);
  125.                 EraseRect(r);
  126.                 MoveTo(165, 362);
  127.                 lastActMsg := me^.action;
  128.                 DrawString(aActionMsg[lastActMsg]);
  129.             end;
  130.         SetRect(r, 720, 350, 750, 366);
  131.         EraseRect(r);
  132.         MoveTo(720, 362);
  133.         NumToString(me^.position.h, s);
  134.         DrawString(s);
  135.  
  136.         ForeColor(blackColor);
  137.         BackColor(whiteColor);
  138.     end; {UpdateInfo}
  139.  
  140.     procedure DrawProgrammerInfo;
  141.         var
  142.             s: Str255;
  143.             r: Rect;
  144.             tmpPort: SATPort;
  145.     begin
  146.         SATGetPort(tmpPort);
  147.         SATSetPortScreen;
  148.         UpdateInfo(playerSp);
  149.         SATSetPort(tmpPort);
  150.     end; {DrawProgrammerInfo}
  151.  
  152. end.